<?php
/**
 * Created by PhpStorm.
 * User: jwb
 * Date: 2021/3/18
 * Time: 18:14
 */

namespace App\Services\Project;


use App\ProjectTcRegister;
use Encore\Admin\Show;
use Encore\Admin\Facades\Admin;


class ProjectRegisterService
{

    public function gridColumn(\Encore\Admin\Grid $grid)
    {
        $that = $this;
        $grid->column('code', __('技术合同登记编号'));
        $grid->column('name', __('技术合同名称'))->modal('详情', function ($project) use ($that) {
            return $that->detail($project);
        });
        $grid->column('type', __('合同类别'));
        $grid->column('transaction_amount', __('合同技术交易总金额'));
        $grid->column('year', __('年度'));
        $grid->column('in_amount', __('实际到账金额'));
        $grid->column('company', __('技术吸纳单位'));
        $grid->column('legal_person', __('法定代表人'))->hide();
        $grid->column('social_credit_code', __('统一社会信用代码'))->hide();
        $grid->column('contact_person', __('单位联系人'))->hide();
        $grid->column('contact_mobile', __('联系电话'))->hide();
        return $grid;
    }

    public function detail(ProjectTcRegister $project)
    {
        return Admin::show($project, function (Show $show) {
            $show->panel()->view('show.tab-panel');
            $show->field('code', '技术合同登记编号');
            $show->field('name', '技术合同名称');
            $show->field('type', '合同类别');
            $show->field('transaction_amount', '合同技术交易总金额');
            $show->field('year', '年度(年)');
            $show->field('in_amount', '实际到账金额');
            $show->field('company', '技术吸纳单位');
            $show->field('legal_person', '法定代表人');
            $show->field('social_credit_code', '统一社会信用代码');
            $show->field('contact_person', '单位联系人');
            $show->field('contact_mobile', '联系电话');
            $show->field('updated_at', '创建时间');
        });
    }

}